#include "library.h"
#include "dma.h"
#include "intc.h"

u8 buf1[32] = "HelloWorld";
u8 buf2[32] = "BOBY";

void __irq DMAHdlr(void)
{
    UART_Printf("DMA int occurred\n");
    INTC_ClearVectAddr();
    INTC_Disable(NUM_DMA0);
}

void DMATest(void)
{
    DMAC dmac;

    DMAC_InitCh(DMA0, DMA_A, &dmac);
    DMACH_Setup(DMA_A, 0x0,
                (u32)buf2, 0,
                (u32)buf1, 0,
                WORD,
                BYTE, DEMAND,
                MEM, MEM, BURST256,
                &dmac);
    UART_Printf("\nBefore copy: %s %s\n", buf1, buf2);
    DMACH_Start(&dmac);
    while (!DMACH_IsTransferDone(&dmac));
    UART_Printf("After copy: %s %s\n", buf1, buf2);
    while (1);
}
